package com.fingard.dsp.bank.directConfig;

import com.fingard.text.StringHelper;
import com.fingard.xml.XElement;

public class NodeAnalysisItem {
    /**
     * 源节点--ATS节点
     */
    public String src;

    /**
     * 备选源节点--如果src为空
     */
    public String srcOption;


    public int cut = 0;
    public String charset;

    /**
     * 目的节点
     */
    public String trg;

    /**
     * 拼接符
     */
    public String union;

    /**
     * 对账码是否保持完整
     */
    public boolean intact;

    public String prefix = "";
    
    /**适用条件，condition="ownBank:102"，适用的条件：工行*/
    public String condition = "";
    /**
     * 字段拆分
     */
    public String split = "";
    /**
     * 字段拆分后获取第几个值(最小值为0)
     */
    public int index = 0;
    public void fromXElement(XElement p_xe) throws Exception {
        if (StringHelper.hasAnyChar(p_xe.getAttrValue("cut"))) {
            cut = Integer.parseInt(p_xe.getAttrValue("cut"));
        }
        if (StringHelper.hasAnyChar(p_xe.getAttrValue("prefix"))) {
            prefix = p_xe.getAttrValue("prefix");
        }
        charset = p_xe.getAttrValue("charset");
        union = p_xe.getAttrValue("union");
        split = p_xe.getAttrValue("split");
        if (StringHelper.hasAnyChar(p_xe.getAttrValue("index"))) {
            index = Integer.parseInt(p_xe.getAttrValue("index"));
        }

        String tmpIntact = p_xe.getAttrValue("intact");
        if (StringHelper.hasAnyChar(tmpIntact) && "false".equals(tmpIntact.toLowerCase())) {
            intact = false;
        } else {
            intact = true;
        }
        condition = p_xe.getAttrValue("condition");

        src = p_xe.getSingleTextNotNull("src");
        trg = p_xe.getSingleTextNotNull("trg");
        srcOption = p_xe.getSingleTextNotNull("srcOption");
        
    }
}
